# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=syslinux
pkgver=6.04_pre1
pkgrel=15
_ver=${pkgver/_/-}
pkgdesc="Boot loader for the Linux operating system"
url="https://syslinux.org"
arch="x86 x86_64"
license="GPL-2.0-or-later"
makedepends="linux-headers nasm perl util-linux-dev gnu-efi-dev"
depends="mtools blkid initramfs-generator"
triggers="syslinux.trigger=/boot"
install="syslinux.post-upgrade"
ldpath="/usr/share/syslinux"
subpackages="$pkgname-doc $pkgname-dev"
source="https://www.kernel.org/pub/linux/utils/boot/syslinux/Testing/${pkgver%_pre*}/syslinux-$_ver.tar.xz
	update-extlinux.conf
	update-extlinux
	0018-prevent-pow-optimization.patch
	fix-sysmacros.patch
	gcc-10.patch
	"

case "$CARCH" in
x86)	_loaderarch=efi32;;
x86_64)	_loaderarch=efi64;;
esac

builddir="$srcdir"/$pkgname-$_ver
options="textrels !check"

build() {
	unset LDFLAGS
	make $_loaderarch installer
}

package() {
	make -j1 INSTALLROOT="$pkgdir" MANDIR=/usr/share/man \
		bios $_loaderarch install

	mkdir -p "$pkgdir"/etc/update-extlinux.d
	cp "$srcdir"/update-extlinux.conf "$pkgdir"/etc/
	sed "/^version=/s/=.*/=$pkgver-r$pkgrel/" "$srcdir"/update-extlinux \
		> "$pkgdir"/sbin/update-extlinux
	chmod 755 "$pkgdir"/sbin/update-extlinux
}

sha512sums="
7927dd39be8e2dcf4138a6fea33def67d19d938379d694f15b48fdd2f5924c028b7a9e7bd71d0c7c6630c203e9e2a54296628e530632ad5e6f55b1ebefe8fc98  syslinux-6.04-pre1.tar.xz
2fb759e483d51769d0259587fe1f48a92d4f95e350f8dc7f055a29da75670617260c0d1a467b63ac05c7719a8fe673ca7f6244011f78592cf750f11acb8d6bb4  update-extlinux.conf
ebd33afdc8c0ea18867f9bc970e54da6b72fc8dddc0475b0d6b24f6c76a1d7d7b8568332f3f9b36122af273d5bd5ea940e8d4aaf978d86029d015329f74c480c  update-extlinux
92fa48133ef702092d7acafae0e0e20f9355cd2b5fe199b96fcccba5a1e688c360de4d069391815255f5493228ad03998d20b99748323396d20d12a1f27c60cd  0018-prevent-pow-optimization.patch
6fb63b50a6c746445a58badc81cbf8525f38e2a7868b97ac21aa9d20c162f2318fab6c25505614700033a840aa5c06c3cef3065f11b5b5f4e514474194ff4b54  fix-sysmacros.patch
62a45f94107300b05a93be18a228c15ae9ce90addeee39a1ef35845077b493e72ebed35791bf8db21c406c379a83220cc4db4e1919c01fcd387ae10b2cfc8861  gcc-10.patch
"
